package dados.persistencias;

import java.util.List;

import javax.persistence.TypedQuery;

import negocio.erro.DaoException;
import basica.academico.Professor;
import basica.administrativo.Pessoa;
import dados.geral.DAOGenerico;
import dados.interfaces.IDAOProfessor;

public class DAOProfessor extends DAOGenerico<Pessoa> implements IDAOProfessor {

	@Override
	public List<Professor> pesquisarProfessorPorCodigo(Integer codigo)
			throws DaoException {
		TypedQuery<Professor> query = entityManager.createQuery(
				"from Professor prof where prof.codigo = :codigo",
				Professor.class);
		query.setParameter("codigo", "%" + codigo + "%");
		return query.getResultList();
	}

	@Override
	public List<Professor> pesquisarProfessoresPorNome(String nome)
			throws DaoException {
		TypedQuery<Professor> query = entityManager.createQuery(
				"from TBPROFESSOR prof where prof.Nome like :nome",
				Professor.class);
		query.setParameter("nome", "%" + nome + "%");
		return query.getResultList();
	}

	@Override
	public List<Professor> pesquisarProfessoresPorRG(String rg)
			throws DaoException {
		TypedQuery<Professor> query = entityManager.createQuery(
				"from TBPROFESSOR prof where prof.RG = :rg", Professor.class);
		query.setParameter("rg", rg);
		return query.getResultList();
	}

}
